from flaskAdminApp import app
from flask_httpauth import HTTPTokenAuth
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer,BadSignature,SignatureExpired


auth = HTTPTokenAuth(scheme='JWT')

@auth.verify_token
def verify_token(token):
    s = Serializer(app.config['SECRET_KEY'])
    try:
        data = s.loads(token)
    except BadSignature:
        # AuthFailed 自定义的异常类型
        return False
    except SignatureExpired:
        return False
        # 校验通过返回True
    return True